package database;


import java.sql.*;

public class ReadData {
	Connection conn = null;
	Statement stmt = null;
	ResultSet rtst = null;
	String sql = "select * from baidu_lr";
	
	public void connection(){
		try{
			Class.forName("com.mysql.jdbc.Driver");
			String url = "jdbc:MySQL://192.168.1.213/videose?user=root&password=ladjzero";
			try{
				conn = DriverManager.getConnection(url);
				stmt = conn.createStatement();
				rtst = stmt.executeQuery(sql);
				
				rtst.last();
				long rowNum = rtst.getRow();
				rtst.first();
				System.out.println("There are "  + rowNum + " rows");
				System.out.println("Here is the first line:");
				System.out.println(rtst.getString(2));
				/*while(rtst.next()){
					//System.out.print(rtst.getString(2));
					System.out.print(rtst.getString("id")+" ");
					System.out.println(rtst.getString("url"));
				}*/
			}catch(SQLException e){
				e.printStackTrace();
			}
		}catch(ClassNotFoundException e){
			e.printStackTrace();
		}finally{
			try {
				rtst.close();
				stmt.close();
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		}
		
	}

}
